local class = reload("class")
local tcpWC = require("tcpWC")
local super = reload("tcpLC")

---@class tcpLWC : tcpLC
local this = class(super)

function this:ctor(name, ip, port)
    super.ctor(self, name, ip, port)
end

function this:launch()
    tcpWC.link(self._name, self._ip, self._port, self)
    return self:hand()
end

---接收文本
function this:recvt(pack)
    local hand = self._hand
    hand.recvt(pack)
end

---进制消息
function this:recvb(mid, pack, cid)
    local hand = self._hand
    hand.recvb(mid, pack, cid)
end

---发送文本
function this:text(pack)
    tcpWC.text(self._name, pack)
end

---发送数据
function this:send(mid, pack)
    local cid = self._cid + 1
    self._cid = cid
    tcpWC.send(self._name, mid, pack, cid)
    return cid
end

---回复数据
function this:reply(mid, pack, cid)
    tcpWC.send(self._name, mid, pack, cid or 0)
end

return this
